package com.trkj.dao.jpa;

import java.util.List;

import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import com.trkj.pojos.YzrPharmacy;

public interface IYzrPharmacyDAO extends CrudRepository<YzrPharmacy, String> {
	
	//根据编号前缀查询出最大的编号
	@Query("select max(p.pharmacyId) from YzrPharmacy p where p.pharmacyId like ?1%")
    public String findID(String a);
	
	//查询所有药房信息
	@Query("select new YzrPharmacy(p.pharmacyId,p.pharmacyAddress,p.pharmacyFuzeren,p.pharmacyName) from YzrPharmacy p order by p.pharmacyId desc")
	public List<YzrPharmacy> findAll(Pageable pageable);
	
	//根据药房名称模糊查询药房
	@Query("select p from YzrPharmacy p where p.pharmacyName like %?1%")
	public List<YzrPharmacy> findByPharmacyNameLike(String pharmacyName);
}
